package Code.Objects.Characters.Player.Weapons;

public class AmmoProfile {
	
	private boolean hasMaxAmmo;
	private int maxAmmo;
	private int currentAmmo;
	
	public AmmoProfile() {
		this(0);
	}
	
	public AmmoProfile(int startAmount) {
		this(startAmount, false, 0);
	}
	
	public AmmoProfile(int startAmount, boolean hasMax, int max) {
		currentAmmo = startAmount;
		hasMaxAmmo = hasMax;
		maxAmmo = max;
	}
	
	public void addAmmo(int amount) {
		currentAmmo += amount;
		validateAmmo();
	}
	
	public void removeAmmo(int amount) {
		currentAmmo -= amount;
		validateAmmo();
	}
	
	public void setCurrentAmmo(int amount) {
		currentAmmo = amount;
		validateAmmo();
	}
	
	public int getCurrentAmmo() {
		return currentAmmo;
	}
	
	public void setMaxAmmo(int max) {
		maxAmmo = max;
		hasMaxAmmo = true;
		validateAmmo();
	}
	
	public int getMaxAmmo() {
		return maxAmmo;
	}
	
	public void setHasMaxAmmo(boolean hasMax) {
		hasMaxAmmo = hasMax;
		validateAmmo();
	}
	
	public boolean getHasMaxAmmo() {
		return hasMaxAmmo;
	}
	
	private void validateAmmo() {
		if (hasMaxAmmo && (currentAmmo > maxAmmo)) {
			currentAmmo = maxAmmo;
		}
		if (currentAmmo < 0) {
			currentAmmo = 0;
		}
	}
	
}
